{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1323
  Verdict: Accepted
}
var i,ls:longint; p:array[0..1000010] of longint; s:string;
procedure prefix(x:string);
var m,k,q:longint;
begin
fillchar(p,sizeof(p),0);
m:=length(x);
p[1]:=0;
k:=0;
for q:=2 to m do begin
  while (k>0) and (x[k+1]<>x[q]) do k:=p[k];
  if x[k+1]=x[q] then inc(k);
  p[q]:=k;
end;
end;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(s);
prefix(s);
ls:=length(s);
for i:=1 to ls do write(p[i],' ');
end.